public class chapter09 {
    public static void main(String[] args) {
        for(int i = 1000;i<10000;i++){
            int g = i%10;
            int s = (i/10)%10;
            int b = (i/100)%10;
            int q = i/1000;
            if((g*g*g*g)+(s*s*s*s)+(b*b*b*b)+(q*q*q*q)==i) {
                System.out.println(i);
            }
        }
    }
}
